import { NestFactory } from '@nestjs/core';
import { AppModule } from './app.module';
import { ValidationPipe } from '@nestjs/common';
import { ConfigService } from '@nestjs/config';
import { FormatResponseInterceptor } from './format-response.interceptor';
import { UnloginFilter } from './unlogin.filter';

async function bootstrap() {
  const app = await NestFactory.create(AppModule);

  app.useGlobalPipes(new ValidationPipe({ transform: true }));
  app.useGlobalInterceptors(new FormatResponseInterceptor());
  app.useGlobalFilters(new UnloginFilter());
  app.enableCors();

  const configService = app.get(ConfigService);
  console.log(
    " 🚀 ~ bootstrap ~ configService.get('nest_server_port')==>",
    configService.get('nest_server_port'),
  );
  await app.listen(configService.get('nest_server_port'));

  // await app.listen(3000);
}
bootstrap();
